/*
	This file is part of PropExtractor.

	PropExtractor is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	PropExtractor is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with PropExtractor. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PEFILE_H_
#define _PEFILE_H_

namespace pe
{

	struct PEStream
	{
		FILE* handle;
		byte* data;

		wchar_t* path;
		wchar_t* dir;
		wchar_t* name;
		wchar_t* ext;

		unsigned int bytesread;
		unsigned int baseoffset;
		unsigned int offset;
		unsigned int maximum;
		unsigned int filesize;
	};

	struct PEFileInfo
	{
		char* company;
		char* type;
		char* comment;
	};

	PE_EXPORT int PEFileInfoParse(PEFileInfo* a_Target, const char* a_String);
	PE_EXPORT int PEFileInfoSetPath(PEFileInfo* a_Target, const wchar_t* a_Path);

	PE_EXPORT int PEStreamOpen(PEStream* a_Target, const wchar_t* a_FilePath, const wchar_t* a_Options = L"rb", bool a_SetPath = true);
	PE_EXPORT int PEStreamSetPathA(PEStream* a_Target, const char* a_FilePath);
	PE_EXPORT int PEStreamSetPath(PEStream* a_Target, const wchar_t* a_FilePath);
	PE_EXPORT int PEStreamSetOffset(PEStream* a_Target, unsigned int a_Offset, unsigned int a_Maximum);
	PE_EXPORT int PEStreamByteOpen(PEStream* a_Target, byte* a_Source, unsigned int a_SizeInBytes);
	PE_EXPORT int PEStreamCopy(PEStream* a_Target, PEStream* a_Source);
	PE_EXPORT int PEStreamRead(PEStream* a_Src, void* a_Dst, unsigned int a_Size, unsigned int a_Count);
	PE_EXPORT int PEStreamSeek(PEStream* a_Target, unsigned int a_Offset, int a_Type);
	PE_EXPORT int PEStreamClose(PEStream* a_Target);
	PE_EXPORT int PEStreamGetBytesRead(PEStream* a_Src, unsigned int* a_Target);
	PE_EXPORT int PEStreamGetCurrentPos(PEStream* a_Src, unsigned int* a_Target);
	PE_EXPORT int PEStreamGetFileSize(PEStream* a_Src, unsigned int* a_Target);
	PE_EXPORT int PEStreamGetFileName(PEStream* a_Src, wchar_t** a_Target);
	PE_EXPORT int PEStreamGetPath(PEStream* a_Src, wchar_t** a_Target);
	PE_EXPORT int PEStreamGetDir(PEStream* a_Src, wchar_t** a_Target);
	PE_EXPORT int PEStreamGetExt(PEStream* a_Src, wchar_t** a_Target);

}; // namespace pe

#endif